package com.utc.fjc.command.newdr;

import com.teamcenter.rac.aif.ICommandListener;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.ui.commands.create.bo.NewBOOperation;
import com.teamcenter.rac.ui.commands.create.bo.NewBOWizard;
import com.utc.teamcenter.common.util.TCUtil;

public class NewDROperation extends NewBOOperation {

	protected void pasteNewComponent(ICommandListener arg0) throws Exception {
		InterfaceAIFComponent[] targets = AIFUtility.getCurrentApplication()
				.getTargetComponents();

		if ((targets != null) && (targets.length > 0)) {
			TCComponent tcComp = (TCComponent) targets[0];

			if ((tcComp != null)
					&& ((tcComp instanceof TCComponentItemRevision))) {
				if ((this.wizard instanceof NewBOWizard)) {
					this.wizard.setRevisionFlag(true);
				}
			}

			if ((tcComp != null) && (tcComp instanceof TCComponentFolder)) {
				super.pasteNewComponent(arg0);
			} else {
				TCComponentFolder newstuff = TCUtil.getTCSession().getUser()
						.getNewStuffFolder();
				newstuff.add("contents", this.newComponent);
			}

		}
		// super.pasteNewComponent(arg0);

	}

}
